﻿using System.Reflection;
using SqlSugar;

namespace MyWeb.Repository.UnitOfWorks
{
    public interface IUnitOfWorkManage
    {
        /// <summary>
        /// 获取数据库连接DB，保证唯一性
        /// </summary>
        /// <returns></returns>
        SqlSugarScope GetDbClient();

        /// <summary>
        /// 事务数
        /// </summary>
        int TranCount { get; }

        UnitOfWork CreateUnitOfWork();
        /// <summary>
        /// 开始事务
        /// </summary>
        void BeginTran();
        /// <summary>
        /// 开始事务
        /// </summary>
        /// <param name="method">事务方法</param>
        void BeginTran(MethodInfo method);
        /// <summary>
        /// 提交事务
        /// </summary>
        void CommitTran();
        /// <summary>
        /// 提交事务
        /// </summary>
        /// <param name="method">事务方法</param>
        void CommitTran(MethodInfo method);
        /// <summary>
        /// 回滚事务
        /// </summary>
        void RollbackTran();
        /// <summary>
        /// 回滚事务
        /// </summary>
        /// <param name="method">事务方法</param>
        void RollbackTran(MethodInfo method);
    }
}